<?php

/*
Setting Up Search For Pets (admin_set_searchpets.pro.php)
*/

$rank_check = "7";
include "../global.inc.php";

$game=$_GET['game'];
$search_pets = $_POST['search_pets'];
$search_items = $_POST['search_items'];

if($search_pets!="")
{
	$explodePets = explode(", ", $search_pets);
	$countPets = count($explodePets) ;

	for ($a = 0; $a <$countPets;)
	{
		$findPet = fetch("SELECT * FROM pets2 WHERE name = '$explodePets[$a]' AND game = '$game'");
		if (!$findPet[id])
		{
			die(header(error("admin_set_searchpets.php?game=$game","The pet \"$explodePets[$a]\" does not exsist!")));
		}
		$a++;
	}
}

if($search_items!="")
{
	$explodeItems = explode(", ", $search_items);
	$countItems = count($explodeItems) ;

	for ($a = 0; $a <$countItems;)
	{
		$findItems = fetch("SELECT * FROM items2 WHERE item_name = '$explodeItems[$a]' AND game = '$game'");
		if (!$findItems[id])
		{
			die(header(error("admin_set_searchpets.php?game=$game","The item \"$explodeItems[$a]\" does not exsist!")));
		}
		$a++;
	}
}

mysql_query("UPDATE search_pets_arrays SET pets = '$search_pets' WHERE game = '$game'");
mysql_query("UPDATE search_pets_arrays SET items = '$search_items' WHERE game = '$game'");

header("Location: admin_set_searchpets.php?game=$game&error=The+game+has+been+setup!");

?>
